<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.jamwiki.model.*,org.jamwiki.*" %> 
<%
   String type = request.getParameter("type");
   String name = request.getParameter("categoryName");
   String cid = request.getParameter("categoryId");
   String sortKey = "1";
		  Category c = new Category();
		  c.setCategoryId(cid);
		  c.setCategoryName(name);
		  c.setSortKey(sortKey);
		  String alertInfo = "";
		 
   if("update".equals(type)){ 
	   WikiBase.getDataHandler().updateCategory(c,null);
   }
   if("newsub".equals(type)){   
	   c.setParentId(cid);
	   WikiBase.getDataHandler().insertCategory(c,null); 
	   cid = WikiBase.getDataHandler().getMaxTopicId()+"";
   }
   if("new".equals(type)){  
       Category inst = WikiBase.getDataHandler().selectCategoryById(Integer.parseInt(cid));
       c.setParentId(inst.getParentId());
	   WikiBase.getDataHandler().insertCategory(c,null); 
	   cid = WikiBase.getDataHandler().getMaxTopicId()+"";
   }

 

%>
<script>
parent.mainFrame.location.reload();
window.location.href="right.jsp?categoryId=<%=cid%>&categoryName=<%=name%>";
 alert("操作成功"); 
 //opener.document.getElementById('categoryName').value="<%=name%>";
 //opener.document.getElementById('categoryId').value="<%=cid%>";
  
</script>